package com.ligotop.admin.system.controller;

import com.ligotop.admin.security.model.AuthUser;
import com.ligotop.admin.system.entity.Menu;
import com.ligotop.admin.system.service.MenuService;
import com.ligotop.admin.utils.SecurityUtil;
import com.ligotop.core.message.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @ResponseBody
    @RequestMapping("/navigationMenus")
    public ResponseMessage loadNavigationMenu() {
        AuthUser authUser = SecurityUtil.getAuthUser();
        List<Menu> menus = menuService.loadMenusByUserId(authUser.getId());
        return ResponseMessage.ok("成功").setData(menus);
    }
}
